home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/mkdir,v $
- * $Date: 1996/10/30 21:59:01 $
- * $Revision: 1.2 $
- * $State: Rel $
- * $Author: unixlib $
- *
- * $Log: mkdir,v $
- * Revision 1.2 1996/10/30 21:59:01 unixlib
- * Massive changes made by Nick Burret and Peter Burwood.
- *
- * Revision 1.1 1996/04/19 21:35:27 simon
- * Initial revision
- *
- ***************************************************************************/
-
- static const char rcs_id[] = "$Id: mkdir,v 1.2 1996/10/30 21:59:01 unixlib Rel $";
-
- #include <errno.h>
- #include <unistd.h>
- #include <sys/os.h>
- #include <sys/stat.h>
-
- int
- mkdir (const char *path, __mode_t mode)
- {
- int r[6];
- _kernel_oserror *e;
- char *dir;
-
- dir = __uname ((char *)path, 1);
-
- if (!os_file (0x05, dir, r))
- {
- if (r[0])
- {
- errno = EEXIST;
- return (-1);
- }
- }
-
- r[4] = 0; /* default entires per dir */
- if (e = os_file (0x08, dir, r))
- {
- __seterr (e);
- return (-1);
- }
-
- /* Set protection for directory. */
- r[5] = (r[5] & 0xFFFFFF00) | ((mode & 0400) >> 8) | ((mode & 0200) >> 6) |
- ((mode & 0004) << 2) | ((mode & 0002) << 4);
-
- if (e = os_file (4, dir, r))
- {
- __seterr (e);
- return (-1);
- }
-
- return (0);
- }
-